<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        input{
            margin-right: 10px;
        }
    </style>
    <script>
        function f() {
            var a = document.getElementById('zfc1').value;
            var b = document.getElementById('zfc2').value;
            var start = 0,count = 0;
            var i = 0;
            while (true){
                i =  b.indexOf(a,start);
                if (i!=-1){
                   start=i+1;
                   count++;
                }else {
                    break;
                }
            }
            document.getElementById('result').innerHTML = "["+a+"]在["+b+"]中一共出现:"+count+"次";
        }
    </script>
</head>
<body>
    <input type="text" id="zfc1"><input type="text" id="zfc2"><button type="button" onclick="f()">开始计算</button>
    <div id="result"></div>
</body>
</html>